<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登陆</title>
</head>
<body>

<div style="margin-left: 716px;margin-top: 100px;">

    <form class="form-horizontal" role="form">
        <div class="form-group" >
            <label for="username" class="col-sm-2 control-label">用户名</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="username" placeholder="请输入用户名">
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-2 control-label">密码</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="password" placeholder="请输入密码">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" onclick="like();" class="btn btn-default">登录</button>
            </div>
        </div>
    </form>


</div>
<script type="text/javascript">

    function like() {
        var username = $("#username").val()
        var password = $("#password").val()
        $.ajax({
            type: "GET",
            url: "http://localhost:5656/user/login?username=" + username + "&password=" + password,
            dataType: "json",
            success: function (data) {
                console.log(data)
                if (data == 1) {
                    alert("登陆成功")
                    window.location="list.html"
                }
                if (data == 2){
                    alert("登陆失败")
                }

                if(data == 3){
                    alert("用户不存在")
                }
            }
        });


    }


</script>

</body>
<!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- 包括所有已编译的插件 -->
<script src="js/bootstrap.js"></script>
</html>